// component/tabbar/tabbar.js
var app = getApp();
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    selected:{
      type:Number,
      value:0
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    color: "#7A7E83",
    selectedColor: "#FF0800",
    list: [{
      pagePath: "/pages/index/index",
      iconPath: "/static/icon/home.png",
      selectedIconPath: "/static/icon/home_red.png",
      text: "首页"
    }, {
      text: "发布"
    }, 
    {
      pagePath: "/pages/person/person",
        iconPath: "/static/icon/user.png",
        selectedIconPath: "/static/icon/user_red.png",
      text: "我的"
    }]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    switchTab(e) {
      var data = e.currentTarget.dataset
      var url = data.path;
      if(url){
        wx.switchTab({ url });
      }else{
        if(app.globalData.token){
          wx.navigateTo({
            url: '/pages/release/release',
          })
        }else{
          console.log(app.globalData.token);
          wx.navigateTo({
            url: '/pages/login/login',
          })
        }
      }
    }
  }
})